<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="(item,index) in numbers" :key="index">
                <span>{{item}}</span>
                <button @click="dilite(index)">删除</button>
            </li>
        </ul>
        <button @click="fun">生成随机数</button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                numbers: []
            },
            methods: {
                // 生成随机数
                fun() {
                    this.numbers.push(parseInt(Math.random() * 21))
                },

                // 删除模块
                dilite(index) {
                    this.numbers.splice(index, 1)
                }
            }
        });
    </script>
</body>

</html>